//
//  NSArray+LBStore.m
//  app
//
//  Created by LINAICAI on 16/6/17.
//  Copyright © 2016年 NAICAI LI. All rights reserved.
//

#import "NSArray+LBStore.h"
/**
 *  目录路径
 */
static const NSString *doc = @"Models";
@implementation NSArray (LBStore)
//初始化信息
-(__kindof NSArray *)load{
    return [NSKeyedUnarchiver unarchiveObjectWithFile:[self path]];
    
}
//保存信息
-(BOOL)save{
    return [NSKeyedArchiver archiveRootObject:self toFile:[self path]];
}
- (NSString *)path{
    NSString *paths = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
    NSString *path = [paths stringByAppendingString:[NSString stringWithFormat:@"/%@/%@.plist",doc,NSStringFromClass(self.class)]];
    return path;
}
- (NSString *)doc{
    NSString *paths = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
    NSString *path = [paths stringByAppendingString:[NSString stringWithFormat:@"/%@",doc]];
    return path;
}
- (void)showAllClass{
   NSArray<NSString *> *array = [[NSFileManager defaultManager]contentsOfDirectoryAtPath:[self doc] error:nil];
    [array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
        NSLog(@"已经再归档中的类:%@",obj);
    }];
}
@end
